package main

import (
	"fmt"
	"math/bits"
)

//#link: https://leetcode-cn.com/problems/binary-watch/
func main() {
	turnedOn := 2
	fmt.Println(readBinaryWatch(turnedOn))
}

//最大只能亮8个LED
func readBinaryWatch(turnedOn int) []string {
	//笨方法是不可取的
	////时只能亮三个 1,2,4,8
	//hour:=make(map[int][]string)
	//hour[0]=[]string{"0:%s"}
	//hour[1]=[]string{"1:%s","2:%s","4:%s","8:%s"}
	//hour[2]=[]string{"3:%s","5:%s","9:%s","6:%s","10:%s","12:%s"}
	//hour[3]=[]string{"7:%s","11:%s"}
	////1,2,4,8,16,32
	//分最多亮5个
	//minute:=make(map[int][]string)
	//minute[0]=[]string{"00"}
	//minute[1]=[]string{"01","02","04","08","16","32"}
	//minute[2]=[]string{"03","05","09","17","33","06","10","18","34","12","20","36","24","40","48"}
	//minute[3]=[]string{"07","11","19","35","14","22","38","28","44","13","21","37","25","41"}
	//minute[4]=[]string{"01","02","04","08","16","32"}
	//minute[5]=[]string{"31","47",""}

	//通过笨方法找见规律 hour:[0,11] minute:[00,59]
	result := make([]string, 0)
	for i := uint(0); i < 2<<10; i++ {
		high, low := i>>6, i&63
		if high < 12 && low < 60 && bits.OnesCount(i) == turnedOn {
			result = append(result, fmt.Sprintf("%d:%02d", high, low))
		}
	}
	return result
}
